package com.example.sixgod;



import android.content.Context;
import android.content.res.Resources;

import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.List;

public class Textchange {
    private  String str;
    StringBuffer sb = new StringBuffer();
    private guaxiang guaxiang;
    Gson gson = new Gson();
    public void change(guaDatabase database,Context context) {
     InputStream inputStream= context.getResources().openRawResource(R.raw.liuyao);
     BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
     StringBuilder sb = new StringBuilder();
     String line;
        try {
            while ((line=reader.readLine()) != null) {
                sb.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        String str1 = sb.toString();
        String[] str2 = str1.split("\\?");
        for (String s : str2) {
            guaxiang = gson.fromJson(s, guaxiang.class);
            database.guaDao().insertGua(guaxiang);
        }
    }



    public Textchange() {
    }
}
